home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T------------------------------------------;
-
- xdef _LaunchTask
- xdef _DPKBase
-
- INCDIR "GMSDev:Includes/"
- INCLUDE "dpkernel/dpkernel.i"
- INCLUDE "files/segments.i"
-
- ;===================================================================================;
- ; LAUNCH CODE
- ;===================================================================================;
- ;This part had to be written in assembler due to the InitDestruct() code, which
- ;requires a correct stack pointer.
-
- SECTION "LaunchTask",CODE
-
- _LaunchTask:
- MOVEM.L D0-D7/A0-A6,-(SP) ;SP = Save registers.
- move.l a0,a5 ;a5 = Segment.
- move.l a1,a4 ;a4 = StartUp.
-
- ;Initialise self-destruct sequence.
-
- move.l _DPKBase(pc),a6 ;a6 = DPKBase.
- lea .exit(pc),a0 ;a0 = Pointer to SelfDestruct() cleanup.
- move.l a7,a1 ;a1 = Stack pointer.
- CALL InitDestruct ;>> = Initialise the call.
-
- ;Setup parameters here. Search for
- ;"PRGM" header to launch program.
-
- move.l SEG_Address(a5),a0 ;a0 = Segment start.
- move.l a0,a1
- lea 64(a1),a1
- .loop cmp.l a1,a0
- bgt.s .exit
- cmp.w #"PR",(a0)+
- bne.s .loop
- cmp.w #"GM",(a0)+
- bne.s .loop
- subq.w #4,a0
- move.l _DPKBase(pc),DPK_DPKBase(a0)
- move.l DPK_Start(a0),a0
-
- sub.l a1,a1 ;a1 = StartUp.
- sub.l a2,a2 ;a2 = Null
- sub.l a3,a3 ;a3 = Null
- sub.l a4,a4 ;a4 = Null
- sub.l a5,a5 ;a5 = Null
- move.l _DPKBase(pc),a6 ;a6 = DPKBase
-
- move.l #$00,d0 ;d0 = ID
- moveq #$00,d1 ;d1 = Null
- moveq #$00,d2 ;d2 = Null
- moveq #$00,d3 ;d3 = Null
- moveq #$00,d4 ;d4 = Null
- moveq #$00,d5 ;d5 = Null
- moveq #$00,d6 ;d6 = Null
- moveq #$00,d7 ;d7 = Null
-
- jsr (a0) ;>> = Start the DPK program.
-
- .exit MOVEM.L (SP)+,D0-D7/A0-A6
- rts
-
- _DPKBase: dc.l 0
-
-